package adnroid.asynchronous.demo;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Demo00AndroidAsynchronousActivity extends Activity{
	private Button	btnThreadAndHandlerUpdateUI = null,
							btnAsyncTaskUpdateUI = null,
							btnThreadLooperAndMessageQueue = null,
							btnUnderstandingAsyncTask = null;
	private Context context = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.main);
		
		btnThreadAndHandlerUpdateUI = (Button)this.findViewById(R.id.btnThreadAndHandlerUpdateUI);
		btnAsyncTaskUpdateUI = (Button)this.findViewById(R.id.btnAsyncTaskUpdateUI);
		btnThreadLooperAndMessageQueue = (Button)this.findViewById(R.id.btnThreadLooperAndMessageQueue);
		btnUnderstandingAsyncTask = (Button)this.findViewById(R.id.btnUnderstandingAsyncTask);
		
		context = Demo00AndroidAsynchronousActivity.this;
		
		btnThreadAndHandlerUpdateUI.setOnClickListener(new OnClickListener(context, Demo01ThreadAndHandlerUpdateUIActivity.class));
		btnAsyncTaskUpdateUI.setOnClickListener(new OnClickListener(context, Demo02AsyncTaskUpdateUIActivity.class));
		btnThreadLooperAndMessageQueue.setOnClickListener(new OnClickListener(context, Demo03ThreadLooperAndMessageQueueActivity.class));
		btnUnderstandingAsyncTask.setOnClickListener(new OnClickListener(context, Demo04UnderstandingAsyncTaskActivity.class));	
	}

	class OnClickListener implements View.OnClickListener {
		private Intent intent = null;
		private Context context = null;
		public OnClickListener(Context context, @SuppressWarnings("rawtypes") Class cls ) {
			this.context = context;
			 intent = new Intent(context, cls);
		}
		public void onClick(View v) {
			// TODO Auto-generated method stub
			context.startActivity(intent);
		}
	}
}
